package com.ddd.test.domainserv.impl;

import java.math.BigDecimal;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ddd.test.aggregate.aggrorder.OrderEntity;
import com.ddd.test.aggregate.aggrsales.SalesEntity;
import com.ddd.test.domainevent.Notice;
import com.ddd.test.domainserv.NewStaffTakesOrders;
import com.ddd.test.repo.OrderRepo;
import com.ddd.test.repo.SalesRepo;

@Service
public class NewStaffTakesOrdersImpl implements NewStaffTakesOrders{

	  @Autowired
	  SalesRepo salesRepo;
	  
	  @Autowired
	  OrderRepo orderRepo;
	  
	  @Autowired
	  Notice notice;
	 
	 
	  public void entryTakeOrders(SalesEntity salesEntity,OrderEntity orderEntity) {
		 if(orderEntity.account().compareTo(new BigDecimal(1000000))>-1) {
			 salesEntity.setLevel(1); //金牌销售
			 salesRepo.add(salesEntity);
			 orderRepo.add(orderEntity);
			 //发布金牌销售入职领域使事件
			 notice.push(salesEntity);
		 }else {
			 salesEntity.setLevel(9); //普通销售
			 salesRepo.add(salesEntity);
			 orderRepo.add(orderEntity);
		 }
	  }	   
}
